package com 
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.text.TextColorType;
	import flash.text.TextFieldType;
	
	/**
	 * ...
	 * @author Mohan Patil
	 */
	public class BlankSpace extends MovieClip 
	{
		private var _textValue:String = "";
		private var _locked:Boolean = false;
		private var _correctValue:String;
		
		public function BlankSpace() 
		{
			txt.addEventListener(Event.CHANGE, textChanged);
		}
		
		private function textChanged(e:Event):void 
		{
			_textValue = txt.text;
			dispatchEvent(new BlankSpaceEvent(BlankSpaceEvent.TEXT_CHANGED, false, false));
		}
		
		public function get textValue():String 
		{
			return _textValue;
		}
		
		public function set textValue(value:String):void 
		{
			_textValue = value;
			txt.text = _textValue;
		}
		
		public function get locked():Boolean 
		{
			return _locked;
		}
		
		public function set locked(value:Boolean):void 
		{
			_locked = value;
			if (_locked)
			{
				txt.type = TextFieldType.DYNAMIC
				txt.selectable = false;
			}
			else
			{
				txt.type = TextFieldType.INPUT;
				txt.selectable = true;
			}
		}
		
		public function get correctValue():String 
		{
			return _correctValue;
		}
		
		public function set correctValue(value:String):void 
		{
			_correctValue = value;
		}
		
		public function showHighlight()
		{
			if (_textValue == _correctValue)
			{
				mcBg.gotoAndStop("correct");
			}
			else
			{
				mcBg.gotoAndStop("incorrect");
			}
		}
		
		public function showCorrectAnswer()
		{
			var prevCorrect:Boolean;
			if (_textValue == _correctValue)
			{
				prevCorrect = true;
			}
			else
			{
				prevCorrect = false;
			}
			
			_textValue = _correctValue;
			txt.text = _textValue;
			if (prevCorrect)
			{
				mcBg.gotoAndStop("correct");
			}
			else
			{
				mcBg.gotoAndStop("incorrect");
			}
		}
		
	}

}